package platform;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import communication.Communicator;

public class SlaveServer {
	
	private Communicator serviceBus;
	
	public SlaveServer() {
		serviceBus = new Communicator("SERVICE_BUS");
		
		serviceBus.addRequestHandler(new StartServiceRequestHandler());
		serviceBus.addRequestHandler(new SlaveServerStatusRequestHandler());
	}
	
	public void run() {
		Logger logger = Logger.getLogger(SlaveServer.class);
		
		logger.info(serviceBus.getAllMembers().size());
	}
	
	public void stop() {
		serviceBus.close();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		BasicConfigurator.configure();
		Logger.getLogger("org.jgroups").setLevel(Level.ERROR);
		
		Logger logger = Logger.getLogger(SlaveServer.class);
		
		SlaveServer server = new SlaveServer();
		
		server.run();
		
		logger.info("Slave server started");
	}

}
